from flask import Flask, request
from flask import render_template
from research import reserch4letters

# Flask:中央登记中心
app = Flask(__name__)


@app.route('/', methods=['GET'])
def hello_world():
    return render_template('Hello.html')


@app.route('/name_index', methods=['GET'])
def name_index():
    return render_template('name_index.html')


# 【POST】实现用户输入，点击提交，将数据提交到 /result
@app.route('/name_result', methods=['POST'])
def name_result():
    py_firstname = request.form['firstname']
    py_lastname = request.form['lastname']
    py_fullname = py_firstname.title() + ' ' + py_lastname.title()

    return render_template('name_result.html',
                           fullname=py_fullname
                           )


@app.route('/word_index', methods=['GET'])
def word_index():
    return render_template('word_index.html')


@app.route('/word_result', methods=['POST'])
def word_result():
    py_word = request.form['word']
    py_vowels = request.form['vowels']
    py_found = reserch4letters(py_vowels, py_word)

    return render_template('word_result.html',
                           found=py_found)


@app.route('/play', methods=['GET'])
def play():
    return render_template('play.html')



@app.route('/shopping_index', methods=['GET'])
def shopping_index():
    return render_template('shopping_index.html')


@app.route('/shopping_result', methods=['POST'])
def shopping_result():
    return render_template('shopping_result.html')


if __name__ == '__main__':
    app.run(host='127.0.0.1', port=5000, debug=True)
